<?php

class Users_Model_Groups extends Light_Db_Table
{
    protected $_name = 'Groups';

    protected $_rowClass = 'Users_Model_Entity_Group';

    /**
     * @return Light_Db_Table_Rowset
     */
    public function getGroups()
    {
        $select = $this->select()->where('admin = 0');

        return $this->fetchAll($select);
    }

    /**
	 * (non-PHPdoc)
	 * @see Light_Db_Table::validate()
	 */
    public function validate(array &$data, Light_Db_Table_Row $item = null)
    {
        $error = array();

        $data = array_map('trim', $data);

        if (!$data['name']) {
            $error['name'] = 'The field is required';
        }

        return $error;
    }
}